#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include<stdio.h>
using namespace std;

class Date
{
public:
    Date(int year = 1, int month = 1, int day = 1)
        : _year(year)
        , _month(month)
        , _day(day)
    {}

    int GetMonthDay(int year, int month)
    {
        static const int days[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,  30, 31 };

        if (month == 2
            && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
        {
            return 29;
        }

        return days[month];
    }

    Date& operator+=(int day)
    {
        _day += day;

        while (_day > GetMonthDay(_year, _month))
        {
            _day -= GetMonthDay(_year, _month);
            _month++;
            if (_month >= 13)
            {
                _year++;
                _month = 1;
            }
        }

        return *this;
    }

    Date Days(int year, int day)
    {
        Date d(year, 1, 1);
        int cnt = 1;
        d += day - 1;

        return d;
    }

    void Print()
    {
        printf("%d-%02d-%02d\n", _year, _month, _day);
    }

private:
    int _year;
    int _month;
    int _day;
};

int main()
{
    int m = 0, n = 0;
    while (scanf("%d %d", &m, &n) != EOF)
    {
        Date ret = Date().Days(m, n);
        ret.Print();
    }

    return 0;
}